package presentacion;

import integracion.DatabaseManager;
import integracion.TareaDAO;



import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import share.Tarea;

//import share.Pelicula; ojo terminar


/**
 * Servlet implementation class for Servlet: Sesion
 *
 */
 public class SeleccionarTarea extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet
 {
   static final long serialVersionUID = 1L;


	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{
		doAll(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
	{
		doAll(request, response);
	}

	private void doAll(HttpServletRequest request, HttpServletResponse response) throws IOException
	{

		if(request.getParameter("accion").equals("SeleccionarTarea"))
		{
			int id = Integer.parseInt(request.getParameter("opciones"));
			System.out.println(id);

			try
			{
				TareaDAO dao = new TareaDAO(DatabaseManager.getConnection());
				Tarea t;
				t=dao.obtenerTarea(id);
				response.sendRedirect("index.jsp?page=OtrosCasos/formularioRealizarTareas&id="+t.getCodigo()+
						"&nombre="+t.getNombre()+"&duracion="+t.getDuracion()+"&bitacora="+t.getBitacora()+
						"&Finicial="+t.getFecha_Inicio()+"&FFinal="+t.getFecha_Final());
				return;

			}
			catch (SQLException e)
			{
				e.printStackTrace();
			}

		}


	}
}